package com.lxq.LeetCode.removeDuplicates;

import java.util.Arrays;

public class Solution {
    public static void main(String[] args) {
        int[] nums = {0,0,1,1,1,2,2,3,3,4};
        System.out.println(removeDuplicates(nums)+" "+ Arrays.toString(nums));

    }

    public static int removeDuplicates(int[] nums) {
        if (nums.length == 0 || nums.length == 1) {
            return nums.length;
        }
        int pRevise = 0, pMove = 1;
        while (pMove < nums.length) {

            if (nums[pRevise] != nums[pMove]) {
                nums[++pRevise] = nums[pMove];
            }
            pMove++;
        }

        return pRevise + 1;
    }
}
